package com.dwxt.cdms.applets;

import com.dwxt.cdms.service.CustomerService;
import com.dwxt.common.annotation.ValidateFiled;
import com.dwxt.common.annotation.ValidateGroup;
import com.dwxt.common.base.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/cdms/small")
@RestController
public class SmallCustomerController {

    @Autowired
    private CustomerService customerService;

    /**
     * 微信用户注册或登录
     * @param phone
     * @return
     */
    @RequestMapping("/selectCustomerInfo")
    @ValidateGroup(fileds = {
            @ValidateFiled(index = 0,regStr = "^1[3|4|5|6|7|8|9][0-9]\\d{4,8}$")
    })
    public BaseResult selectCustomerInfo(String phone){
        return customerService.insertAndSelectCustomerInfo(phone);
    }

    /**
     * 查询客户信息
     * @param customerId
     * @return
     */
    @RequestMapping("/selectCustomerInfoById")
    public BaseResult selectCustomerInfoById(@RequestParam(required = true,name = "customerId") Integer customerId){
        return customerService.selectCustomerInfoById(customerId);
    }

}
